package com.remainder.sdk.export.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.remainder.oss.s3.core.OssTemplate;
import com.remainder.sdk.export.mapper.ExportLogMapper;
import com.remainder.sdk.export.service.BatchExport;
import com.remainder.sdk.export.service.impl.BatchExportImpl;
import com.remainder.sdk.export.service.impl.ExportLogService;
import com.remainder.system.api.RemoteConfigService;

/**
 * 导出sdk配置加载类
 *
 * @author qiaomignzhi
 * @date 2023-06-13
 */
@Configuration
@MapperScan("com.remainder.sdk.export.mapper.**")
public class ExportSdkConfig {

    @Bean
    public ExportLogService exportLogSyncServiceImpl(ExportLogMapper exportLogMapper) {
        return new ExportLogService(exportLogMapper);
    }

    @Bean
    @ConditionalOnBean(value = {ExportLogService.class, OssTemplate.class, RemoteConfigService.class})
    public BatchExport batchExportImpl(ExportLogService exportLogSyncServiceImpl, OssTemplate<Object> ossTemplate,
        RemoteConfigService remoteConfigService) {
        return new BatchExportImpl<>(exportLogSyncServiceImpl, ossTemplate, remoteConfigService);
    }

}
